<?php
	include_once("db/CaseType.inc");

	$d = null;
	
	if (isset($_REQUEST["code"]))
		$d = CaseType::getCaseType($_REQUEST["code"]);
	
	$isNew = $d == null;
	$title = ($isNew) ? "Add New Case Type" : "Edit Case Type - $d->id";
?>

<h1><?php print $title?></h1>
	
<form id="caseTypeForm" method="post" action="?action=setCaseType">
	<table cellspacing="0" class="formLayout">
		<tr>
			<td>ID</td>
			<td><input type="text" id="code" name="code" maxlength="4" readonly
					value="<?php 
						if (!$isNew)
							print $d->id;
					?>" /></td>
		</tr>
		
		<tr>
			<td>Name</td>
			<td><input id="name" type="text" name="name"
				 value ="<?php if (!$isNew) {
						print $d->name;
					 } ?>" />
			<td>
		</tr>
		
		<tr colspan="2">
			<td>
				<input type="submit" value="Confirm" class="button"/>
				<input type="button" value="Cancel" class="button" onClick="window.location.href='?action=viewCaseType'" />
			</td>
		</tr>
	</table> 
</form>
